<?php
namespace app\common\repositories\user;
use app\common\repositories\BaseRepository;
use app\common\dao\user\UserFocusDao as dao;
/**
 * @mixin dao
 */
class UserFocusRepository extends BaseRepository
{
    public function __construct(dao $dao)
    {
        $this->dao = $dao;
    }

    /**
     * 关注列表
     * @param $where
     * @param $page
     * @param $limit
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getFocusList($where,$page,$limit)
    {
        $count = $this->search($where)->count();

        $list = $this->search($where)->page($page,$limit)->with([
            'focus'
        ])->order('focus_id desc')->select();

        return compact('count','list');
    }

    /**
     * 粉丝列表
     * @param $where
     * @param $page
     * @param $limit
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getFansList($where,$page,$limit)
    {
        $count = $this->search($where)->count();

        $list = $this->search($where)->page($page,$limit)->with(['fans'])->order('focus_id desc')->select();

        return compact('count','list');
    }

}